#include "event_list.h"
#include "queue.hpp"
#include <queue>
#include <iostream>
using namespace std;

Event_Notice::Event_Notice(event_t t, double rt, double ot, Job *job, Queue *source, Queue *dest)
  : event_type(t), reg_time(rt), occ_time(ot), job(job), source(source), dest(dest) {}

bool Event_Notice::operator<(const Event_Notice &e) const {
  return occ_time > e.occ_time;
}
  
double Event_Notice::get_occ_time() {
  return occ_time;
}

Job *Event_Notice::get_job() {
  return job;
}

Queue *Event_Notice::get_source() {
  return source;
}

Queue *Event_Notice::get_dest() {
  return dest;
}

event_t Event_Notice::get_event_type() {
  return event_type;
}

std::ostream &operator<<(std::ostream &os, const Event_Notice &e) {
  return os << "[" << e.occ_time << "] " << *e.source << " -> " << *e.dest;
}

bool Event_Notice_Compare::operator()(const Event_Notice *e1, const Event_Notice *e2) {
  return *e1 < *e2;
}

Event_Notice *Event_List::fetch() {
  Event_Notice *res = event_list.top();
  event_list.pop();
  return res;
}

void Event_List::schedule(Event_Notice *e) {
  event_list.push(e);
}

unsigned long Event_List::size() {
  return event_list.size();
}

std::ostream &operator<<(std::ostream &os, const Event_List &l) {
  return os << l.event_list.size() << " sched. events. First: " << *l.event_list.top();
}
